package com.ada.filter;

import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.rpc.*;
@Activate(group = {CommonConstants.CONSUMER})
public class TPMonitorFilter implements Filter {



    @Override
    public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
        long start = System.currentTimeMillis();

        Result result= invoker.invoke(invocation);

        //记录一下
        long duration = System.currentTimeMillis() - start;
        String method = invocation.getMethodName();
        MethodUtil.record(method,duration,System.currentTimeMillis());
        return result;
    }


}
